package com.greenhouse.service.impl;

import com.greenhouse.mapper.greenhouse.CropInfoMapper;
import com.greenhouse.model.CropInfo;
import com.greenhouse.service.CropInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CropInfoServiceImpl implements CropInfoService {
    @Autowired
    private CropInfoMapper cropInfoMapper;
    @Override
    public Boolean addCrop(CropInfo cropInfo) {
        Integer n = cropInfoMapper.insertCropInfo(cropInfo);
        if (n == 1){
            return true;
        }
        return false;
    }

    @Override
    public List<CropInfo> showCrop() {
        List<CropInfo> list = cropInfoMapper.getCropInfoList();
        return list;
    }

    @Override
    public Boolean deleteCrop(Integer cropId) {
        Integer n = cropInfoMapper.deleteCrop(cropId);
        if (n == 1){
            return true;
        }
        return false;
    }

    @Override
    public CropInfo updateCrop(CropInfo cropInfo) {
        Integer n = cropInfoMapper.updateCropInfo(cropInfo);
        if (n == 1){
            return cropInfo;
        }
        return null;
    }
}
